package com.fitmanagement.controller;


import com.fitmanagement.entity.Result;
import com.fitmanagement.utils.JwtUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 虚空
 * @since 2024-10-25
 */
@RestController
@RequestMapping("/dietplans")
public class DietplansController {
    @GetMapping("/diet")
    public Result<String> list(@RequestHeader(name= "Authorization") String token, HttpServletResponse response){
        //验证token
    try{    Map<String, Object> claims = JwtUtil.parseToken(token);
        System.out.println(claims);
    }
    catch(Exception e){
        response.setStatus(401);

            return Result.error("token验证失败", e.getMessage());
        }

        return Result.success("sad");
    }

}
